//#include "contentarea.h"
//#include <QScrollArea>
//#include <QHBoxLayout>
//#include <QVBoxLayout>
//#include <QStyleOption>
//#include <QPainter>

//ContentArea::ContentArea(QWidget *parent) : QWidget{parent}{

//    contents = new QWidget(this);
//    QString styleSheet = "background-color: transparent;"
//                         "border: 1px solid transparent;"
//                         "border-radius: 20px;";
//    contents->setStyleSheet(styleSheet);

//    contents->setFixedSize(360, 1000);

//    QHBoxLayout *HLayout = new QHBoxLayout(this);

//    // 滑动区域
//    ScrollArea = new QScrollArea(this);
//    ScrollArea->setFixedSize(380, 670);


//    // contents布局控件
//    VLayout = new QVBoxLayout(this);

//    VLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
//    VLayout->setContentsMargins(0, 0, 0, 0);
//    // 设置布局管理器的间距为20
//    VLayout->setSpacing(10);
//    //VLayout->addStretch();
//    contents->setLayout(VLayout);
//    contents->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);


//    ScrollArea->setWidget(contents);

//    this->setLayout(HLayout);
//    HLayout->addWidget(ScrollArea);
//    HLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);

//    HLayout->setContentsMargins(0, 0, 0, 0);
//    // 设置布局管理器的间距为20
//    HLayout->setSpacing(10);
//    HLayout->addStretch();


//}


//void ContentArea::paintEvent(QPaintEvent *event)
//{
//    // 启用样式表
//    QStyleOption opt;
//    opt.initFrom(this);
//    QPainter p(this);
//    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);

//    // 以样式表方式重绘自身
//    QString styleSheet = "background-color: transparent;"
//                         "border: 1px solid transparent;"
//                         "border-radius: 25px;";
//    setStyleSheet(styleSheet);
//    //BSbar->set();
//    setFixedSize(390, 670);
//    move(5, 75);

//}


#include "contentarea.h"
#include <QScrollArea>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QStyleOption>
#include <QPainter>

ContentArea::ContentArea(QWidget *parent) : QWidget(parent) {
    setAutoFillBackground(true);
    setStyleSheet("background-color: transparent;"
                  "border: 1px solid transparent;"
                  "border-radius: 20px;");
    setFixedSize(390, 670);
    move(5, 75);

    QHBoxLayout *HLayout = new QHBoxLayout(this);

    // 滑动区域
    ScrollArea = new QScrollArea(this);
    ScrollArea->setFixedSize(380, 670);

    // contents布局控件
    VLayout = new QVBoxLayout(this);
    VLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    VLayout->setContentsMargins(0, 0, 0, 0);
    VLayout->setSpacing(10);
    ScrollArea->setWidgetResizable(true);

    contents = new QWidget(this);
    contents->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    contents->setLayout(VLayout);
    ScrollArea->setWidget(contents);

    HLayout->addWidget(ScrollArea);
    HLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    HLayout->setContentsMargins(0, 0, 0, 0);
    HLayout->setSpacing(10);
}

void ContentArea::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event);

    QPainter p(this);
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
